<%--
    Document   : index
    Created on : 02 4, 12, 12:10:01 PM
    Author     : Martin Spencer Sy
--%>

<%@page import="Controller.UserManager"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <%
        String user = (String)session.getAttribute("user");
        String name = (String)session.getAttribute("name");
        
        //if user is logged in
        if( user != null ){
            response.sendRedirect("main.jsp");
        }
    %>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        
        <link rel="stylesheet" href="css/960_24_col.css" />
        <link rel="stylesheet" href="css/reset.css" />
        <link rel="stylesheet" href="css/text.css" />
        <link rel="stylesheet" href="css/style.css" />
        
        <title>FooBar Online Bookstore</title>
    </head>
    <body>
        <div id="bar"></div>
        <!-------------------------------header here----------------------->
            <div id="header-wrap">
                <div id="dashboard" class="container_24">
                    <div id="dashboard-logo" class="grid_7">
                        <a href="index.jsp"><img src="images/logo.png" alt="logo" /></a>
                    </div>
                    <div id="dashboard-menu" class="grid_17">
                        <ul class="menu" id="main-menu">
                            <li><a href="index.jsp">Home</a></li>
                            <li><a href="main.jsp">Products</a>
                                <ul style="display: none;">
                                    <li><a href="main.jsp?show=book">Books</a></li>
                                    <li><a href="main.jsp?show=mags">Magazines</a></li>
                                    <li><a href="main.jsp?show=cd">CD</a></li>
                                    <li><a href="main.jsp?show=dvd">DVD</a></li>
                                    <li><a href="main.jsp?show=acc">Accessories</a></li>
                                </ul>
                            </li>
                            <%
                            if( user != null && UserManager.isAdmin(user) == 0 && UserManager.isFinanceManager(user) == 0 && UserManager.isProductManager(user) == 0 ){
                                out.println("<li><a href='myProfile.jsp'>My Profile</a></li>");
                            }
                            else if(UserManager.isAdmin(user) == 1){
                                out.println("<li><a href='admin/adminPanel.jsp'>Admin Panel</a></li>");
                            }
                            else if(UserManager.isFinanceManager(user) == 1){
                                out.println("<li><a href='admin/financePanel.jsp'>Sales Panel</a></li>");
                            }
                            else if(UserManager.isProductManager(user) != 0){
                                out.println("<li><a href='admin/productPanel.jsp'>Product Panel</a></li>");
                            }
                            %>
                            <li><a href="about.jsp">About</a></li>
                            <li><a href="contact.jsp">Contact Us</a></li>
                            <%
                            if(user == null){
                                out.println("<li><a href='login.jsp'>Login</a> | <a href='register.jsp'>Join Now</a></li>");
                            }
                            else{
                                out.println("<li><form action='logout' name='logout' method='post'>"
                                + "<a id='user-header' href='myProfile.jsp'>" + name + "</a>"
                                + "<input type='submit' value='Logout' class='submit-button' />"
                                + "</form></li>");
                            }
                            %>
                        </ul>
                    </div>
                </div>
            </div>
        <!-------------------------------content here----------------------->
        <div id="content-wrap">
            <div id="content" class="container_24">
                <h1>Forgot your Password?</h1>
                
                <div class="grid_7">
                    <form action="ForgotPW" method="post" id="forgot-pw-form" class="styled-form">
                        <label>Username: </label><br />
                        <input type="text" name="username" class="form-inputs" />
                        <br />
                        
                        <label>E-mail: </label><br />
                        <input type="text" name="email" class="form-inputs" />
                        <br />
                        
                        <input type="submit" value="Submit" class="submit-button" />
                    </form>
                </div>
                <div class="grid_12 suffix_5">
                    
                    <ul class="error-pane">
                    <%
                    try{
                        if( request.getParameter("result").equals("1") ){
                            out.println("<li class='important'>Your Password Has Been Sent To Your E-mail</li>");
                        }
                        else if( request.getParameter("result").equals("0") ){
                            out.println("<li class='important'>Invalid Username or E-mail</li>");
                        }
                        else if( request.getParameter("result").equals("2") ){
                            out.println("<li class='important'>User is Already Locked Out</li>");
                        }
                        else if( request.getParameter("result").equals("-1") ){
                            out.println("<li class='important'>Ooops Something Went Wrong Try Again Later</li>");
                        }
                    }
                    catch(NullPointerException e1){
                        
                    }
                    catch(Exception e){
                        
                    }
                    %>
                    </ul>
                </div>
            </div>
        </div>
        <!-------------------------------footer here----------------------->
        <div id="footer-wrap">
            <div id="footer" class="container_24">
                
            </div>
        </div>
    </body>
</html>
